<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>报销管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="__TMPL__/layui/css/layui.css" media="all">
	<link rel="stylesheet" href="__TMPL__/css/admin.css" media="all">
	<script type="text/javascript" src="__TMPL__/js/jquery.min.js"></script>
	<script type="text/javascript" src="__TMPL__/layui/layui.js"></script>
	<script type="text/javascript" src="__TMPL__/js/admin.js"></script>
    <script type="text/javascript" src="__TMPL__/layui/lay/modules/util.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <select name="cycle_id">
                            <volist name="cycle_list" id="vo">
                                <option value="{$vo.id}">{$vo.name}</option>
                            </volist>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-admin" lay-submit="" lay-filter="search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                    <if condition="$count==1">
                        <button class="layui-btn layuiadmin-btn-admin layui-btn-normal" lay-submit="" lay-filter="add">
                            <i class="layui-icon layui-icon-add-circle-fine layuiadmin-button-btn" style="top: -2px"></i>添加
                        </button>
                        <else/>
                        <button class="layui-btn layuiadmin-btn-admin layui-btn-disabled" >
                            <i class="layui-icon layui-icon-add-circle-fine layuiadmin-button-btn" style="top: -2px"></i>不在报销时段
                        </button>
                    </if>
                </div>
            </div>
        </div>
        <div class="layui-card-body">
            <table id="dataTable" lay-filter="dataTable"></table>
            <script type="text/html" id="status">
                {{# if(d.status == 0){ }}
                <button class="layui-btn layui-btn-xs layui-btn-disabled" >审核中</button>
                {{# }else if(d.status == 1){ }}
                <button class="layui-btn layui-btn-xs" >已完成</button>
                {{# }else if(d.status == 2){ }}
                审核中
                {{# }else if(d.status == 3){ }}
                审核完成
                {{# }else if(d.status == 4){ }}
                审核中
                {{# }else if(d.status == 5){ }}
                <span style="color: red">驳回({{d.reason}})</span>
                {{# } }}
            </script>
            <script type="text/html" id="apply_time">
                {{ time2date(d.apply_time) }}
            </script>
        </div>
    </div>
</div>
<script type="text/html" id="check">
    <input type="radio" name="layTableCheckbox" value="{{d.id}}" lay-filter="check">
</script>
<script>
    layui.config({
        base: '__TMPL__/public/', //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['layer', 'table', 'form','laydate'], function () {
        var table       = layui.table,
            layer       = layui.layer,
            laydate     = layui.laydate,
            form        = layui.form,
            admin       = layui.admin;
        laydate.render({
            elem: '#time'
            ,type: 'month'
        });
        form.on('submit(search)', function(data){
            var field = data.field;
            //执行重载
            table.reload('dataTable', {
                where: field
            });
        });
        form.on('submit(add)', function(data){
            var index = layer.open({
                type: 2
                ,title: '添加报销'
                ,content: "/admin/baoxiao/info"
                ,maxmin: true
                ,area: ['700px', '560px']
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    var submit = layero.find('iframe').contents().find("#layuiadmin-app-form-submit");
                    submit.click();
                }
            });
            layer.full(index);
        });
        //用户表格初始化
        var dataTable = table.render({
            elem: '#dataTable'
            , url: "{:url('baoxiao/data')}" //数据接口
            ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter', 'exports', 'print']
            , page: true //开启分页
            , response: {
                statusCode: 1
            }
            , cols: [[ //表头
                {checkbox: true, fixed: true}
                ,{field: 'name', title: "姓名"}
                , {field: 'apply_time', title: "时间",width:200}
                , {field: 'money', title: "金额"}
                , {field: 'remark', title: "用途"}
                , {field: 'status', title: "状态", toolbar: '#status'}
            ]]
        });

    });
    function time2date(t) {
        var t1 = parseInt(t + '000');
        return layui.util.toDateString(t1);
    }
</script>
</body>
</html>